package com.gkoudai.open.platform.listener;

import com.gkoudai.open.platform.client.SocketIoClient;
import com.gkoudai.open.platform.handler.DataHandler;
import io.socket.emitter.Emitter;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author : Amater
 * @date : 2024/10/28 20:27
 */
@Slf4j
@AllArgsConstructor
public class ConnectErrorListener implements Emitter.Listener {
    private DataHandler dataHandler;
    private SocketIoClient socketIoClient;

    @Override
    public void call(Object... objects) {
        if (dataHandler != null) {
            dataHandler.connectError(objects);
        } else {
            log.info("ConnectError message:{}", objects);
        }
        socketIoClient.reconnect();
    }
}
